/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-02-10 16:33:05
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-09-25 15:55:41
 * @FilePath: \cxl-admin\src\apis\operation\product.ts
 */
import axios from '../../axios/index'

export interface productInterface {
    basicPrice: number
    productType: number
    singlePrice: number
    id?: string
}

export const addProduct = (data: productInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/product/config/add',
        data
    })
}
/**
 * 编辑产品价格
 * @param id
 * @param productType 产品类型（1.车况-出险；2.车况-维保车况）
 * @param singlePrice
 * @returns
 */
export const editProduct = (data: productInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/product/config/edit',
        data
    })
}

/**
 * 禁用/启用产品价格
 * @param id
 * @param productType 产品类型（1.车况-出险；2.车况-维保车况）
 * @param status 状态（0.禁用；1.启用）
 * @returns
 */
export const enableProduct = (id: string, productType: number, status: number) => {
    return axios({
        method: 'post',
        url: '/api/mall/product/config/enable',
        data: { id, productType, status }
    })
}

interface paramsInterface {
    current: number
    size: number
    productType?: number //产品类型（1.车况-出险；2.车况-维保车况）
    status?: number //状态（0.禁用；1.启用）
}

/**
 * 查询产品分页
 * @param params
 * @returns
 */
export const listProduct = (params: paramsInterface) => {
    return axios({
        method: 'get',
        url: '/api/mall/product/config/list',
        params
    })
}

export const deleteProduct = (id: string) => {
    return axios({
        method: 'post',
        url: '​/api​/mall​/product​/config​/delete',
        data: { id }
    })
}
